package com.zsy.springframework.beans.factory.beanfactory;

import com.zsy.springframework.beans.factory.jiekou.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

//DefaultSingletonBeanRegistry：对接口SingletonBeanRegistry各函数的实现。
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    //把单例的bean都放到这里面
    private final Map<String, Object> singletonObjects = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    protected void addSingleton(String beanName, Object singletonObject) {
        singletonObjects.put(beanName, singletonObject);
    }
}
